﻿<html lang="zh-cn">
<head>
<title>智能家居控制板</title>
<meta charset="utf-8">
<script>
function loadXMLDoc(path,element)
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp=new XMLHttpRequest();
    }
    else
    {
        // IE6, IE5 浏览器执行代码
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById(element).innerHTML=xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET",path,true);
    xmlhttp.send();
}
</script>
<script>
function UpdateInfo()
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp=new XMLHttpRequest();
    }
    else
    {
        // IE6, IE5 浏览器执行代码
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            var arr=xmlhttp.responseText.split(",");

            document.getElementById('TimeDiv').innerHTML=arr[0];

            document.getElementById('Text1').innerHTML=arr[1];
            document.getElementById('Text2').innerHTML=arr[2];
            document.getElementById('Text3').innerHTML=arr[3];

        }
    }
    xmlhttp.open("GET",'/update',true);
    xmlhttp.send();
}
</script>
<script>
    function MyAutoRun()
    { 
       UpdateInfo();
    } 
    setInterval("MyAutoRun()",1000);
</script>
</head>
<body style="background-color:black;color:white">


    <font size=20>
        <div id="TimeDiv">datetime</div>
    </font>

    <div id="OperationHit"><h2></h2></div>

    <table border="1">
        <tr>
            <th>设备</th>
            <th>状态</th>
            <th>操作</th>
        </tr>

        <tr>
            <td>客厅灯光</td>
            <td><div id="Text1"><h2></h2></div></td>
            <td>
                <table border="0" align="right">
                    <tr>
                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=0&Operation=0','OperationHit')">开</button></td>
                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=0&Operation=1','OperationHit')">关</button></td>

                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=0&Operation=3','OperationHit')">开</button></td>
                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=0&Operation=4','OperationHit')">关</button></td>
                    </tr>
                </table>
            </td>
        </tr>

        <tr>
            <td>主卧灯光</td>
            <td><div id="Text2"><h2></h2></div></td>
            <td>
                <table border="0" align="right">
                    <tr>
                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=1&Operation=0','OperationHit')">开</button></td>
                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=1&Operation=1','OperationHit')">关</button></td>

                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=1&Operation=3','OperationHit')">开</button></td>
                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=1&Operation=4','OperationHit')">关</button></td>
                    </tr>
                </table>
            </td>
        </tr>

        <tr>
            <td>次卧灯光</td>
            <td><div id="Text3"><h2></h2></div></td>
            <td>
                <table border="0" align="right">
                    <tr>
                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=2&Operation=0','OperationHit')">开</button></td>
                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=2&Operation=1','OperationHit')">关</button></td>

                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=2&Operation=3','OperationHit')">开</button></td>
                        <td><button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=2&Operation=4','OperationHit')">关</button></td>
                    </tr>
                </table>
            </td>
        </tr>

    </table>
</body>
</html>